<extend name="template/base_index" />
<block name="area_header">
	<link rel="stylesheet" type="text/css" media="all" href="__CDN__/jquery-datetimepicker/jquery.datetimepicker.css">
	<script type="text/javascript" src="__CDN__/jquery-datetimepicker/jquery.datetimepicker.js"></script>
	<script src="__LEARUN__/js/index.js"></script>
</block>
<block name="area_body">
	{:W('Menus/topbar')}
	<div class="admin-main container-fluid">
		{:W('Menus/left')}
		<div class="admin-main-content">
			{:W('Menus/breadcrumb')}
			<!--<notempty name="parent_vo">-->
			<!--<div class="text-center">-->
                <!--<h4>-->

					<!--<notempty name="preparent_vo">-->
					<!--<a href="{:U('Admin/Category/index',array('parent'=>$preparent_vo['id']))}">{$preparent_vo.name}>>-->
					<!--</a></notempty>-->
					<!--<a href="{:U('Admin/Category/index',array('parent'=>$parent_vo['id']))}">	{$parent_vo.name}-->
					<!--</a>-->
				<!--</h4>-->
            <!--</div>-->
			<!--</notempty>-->
            <!--<div class="alert alert-info">-->
                 <!--注意:点击类目进入子类目-->
            <!--</div>-->
			<!-- 过滤\查询按钮 -->
				<div class="filter-controls">
					<!-- 日期查询 -->
					<form action="{:U('Admin/Category/index',array('parent'=>$parent,'preparent'=>$preparent))}" method="post" class="form-inline hide" id="fm">
						<div class="form-group">
							<label>类目名称</label>
							<input type="text" name="name" placeholder="请输入类目名称" value="{$name}" class="form-control input-short input-sm"/>
						</div>
						<button type="submit" class="btn btn-default btn-sm"><i class="fa fa-search"></i>{:L('BTN_SEARCH')}</button>
						<!--<select name="lang" id="sel" style="" class="form-control input-short input-sm select_type">-->
							<!--<volist name="lang_list" id="vo">-->
								<!--<option value="{$vo.value}" <eq name="vo['value']" value="$sel" >selected="selected"</eq> >{$vo.name}</option>-->
							<!--</volist>-->
						<!--</select>-->
					</form>
				</div>
				<!-- 操作按钮 -->
				<div class="btn-controls">
					<!--<notempty name="parent">-->
						<!--<a href="{:U('Admin/Category/index',array('lang'=>$sel,'parent'=>$preparent))}" class="btn btn-default btn-sm"><i class="fa fa-reply"></i>返回上级类目</a>-->
					<!--</notempty>-->
						<div style="margin-bottom: 15px;" class="text-left">
						类目导航：
							<a href="{:U('Admin/Category/index',array('parent'=>0))}">最上级类目>>
								<notempty name="preparent_vo">
									<a href="{:U('Admin/Category/index',array('parent'=>$preparent_vo['id']))}">{$preparent_vo.name}>>
									</a></notempty>
								<a href="{:U('Admin/Category/index',array('parent'=>$parent_vo['id']))}">	{$parent_vo.name}
								</a>
						</div>
					<a href="#" data-url="{:U('Admin/Category/saveSort',array('lang'=>$sel,'parent'=>$preparent))}" class="j_sort btn btn-default btn-sm"><i class="fa fa-save"></i>保存排序</a>
					<a class="btn btn-primary btn-sm" href="{:U('Admin/Category/add',array('lang'=>$sel,'parent'=>$parent,'preparent'=>$preparent,'level'=>($level)))}"><i class="fa fa-plus"></i>类目添加</a>
					<a href="{:U('Admin/Category/import')}" class="btn btn-sm btn-default">类目导入</a>

    <a class="btn btn-link" target="_blank" href="__PUBLIC__/Admin/download/category.xlsx">下载类目模板excel</a>
</div>
<table class="table table-striped table table-hover table-condensed">
    <thead>
        <tr>
            <th>
                <!--<input type="checkbox" class="selectall" onclick="myUtils.selectall(this,'.selectitem');" />-->编号
							</th>
							<th width="220px;">
								名称
							</th>
							<th width="180px;" class="fp">
								属性管理
							</th>
							<!--<th width="180px;" class="fp">-->
								<!--规格管理-->
							<!--</th>-->
							<th width="180px;" class="fp">
								级别
							</th>
							<th width="180px;" class="fp">
								排序
							</th>
							<th>
								操作
							</th>
						</tr>
					</thead>
					<tbody>
						<empty name="list">
							<tr>
								<td colspan="4" class="text-center">{:L('NO_DATA')}</td>
							</tr>
							<else/>
							<volist name="list" id="vo">
								<tr>
									<td>
										<!--<input type="checkbox" value="{$vo.id}" name="ids[]" class="selectitem" />	-->{$vo.id}
									</td>
									<td>{$vo.name}
										<!--{$vo.name}-->
										<!--<if condition=" $vo['level'] gt 2 ">&#45;&#45;&#45;&#45;&#45;&#45;{$vo.name}-->
										<!--<else/>-->
										<!--<a href="{:U('Admin/Category/index',array('level'=>$vo['level'],'parent'=>$vo['id'],'preparent'=>$vo['parent']))}">-->
											<!--{:str_repeat("&#45;&#45;",$vo['level']-1)}-->
											<!--{$vo.name}-->
											<!--</a>-->
										<!--</if>-->
									</td>
									<td >

										<if condition=" $vo['level'] gt 2 ">--
											<else/>
										<a class="prop"  href="{:U('Admin/CategoryProp/index',array('cate_id'=>$vo['id']))}" > 属性管理</a>
										</if>

                                    </td>
									<!--<td>-->
										<!--<if condition="$vo['level'] gt 2">-->
											<!--<a   href="{:U('Admin/CategorySku/index',array('cate_id'=>$vo['id'],'parent'=>$parent,'preparent'=>$preparent,'level'=>($level)))}">规格管理</a>-->
											<!--<else/>-->
											<!--&#45;&#45;-->
										<!--</if>-->
									<!--</td>-->
									<td >
										{$vo.level}级类目
									</td>
									<td >
										<input type="text" style="width: 40px;" value="{$vo.display_order}" name="sort[]" class="sort" />

									</td>
									<td>
										<!--<if condition="$vo['level'] lt 3">-->

										<!--<a href="{:U('Admin/Category/import',array('parent'=>$vo['id'],'root_id'=>($vo['level'] == 1?$vo['id']:$vo['root_id'])))}" class="btn btn-sm btn-default">导入{:($vo['level']==1?"二级":"三级")}类目</a>-->

										<!--</if>-->
										<a href="{:U('Admin/Category/edit',array('id'=>$vo['id'],'parent'=>$vo['parent'],'preparent'=>$preparent,'lang'=>$sel))}" class="btn btn-sm btn-default"><i class="fa fa-edit"></i>编辑</a>
										<a href="{:U('Admin/Category/delete',array('id'=>$vo['id']))}" class="btn btn-sm btn-danger ajax-get confirm"><i class="fa fa-trash"></i>删除</a>
										<!--<a href="{:U('Admin/Category/delete',array('id'=>$vo['id']))}" class="btn btn-sm btn-danger ajax-get confirm"><i class="fa fa-trash"></i>删除所有子类目</a>-->
									</td>
								</tr>

							</volist>
						</empty>
					</tbody>
				</table>
				<div>{$show}</div>
			</div>
		</div>
		<!-- END admin-main-content -->
	</div>
		<!-- END admin-main-->
</block>

<block name="area_footer">
	<script type="text/javascript">
		$(function () {

//			if($('#fp').attr('level') < 2){
//				$(".prop").hide();
//			}
			if($('#fp').attr('level') > 2){
				$(".prop").hide();
			}
			$('#startdatetime').datetimepicker({
				lang: 'ch',
				format:'Y-m-d',
				timepicker:false,
                timepickerScrollbar:false,
                scrollMonth:false,
                scrollTime:false,
                scrollInput:false
			});
			$('#enddatetime').datetimepicker({
				lang: 'ch',
				format:'Y-m-d',
				timepicker:false,
                timepickerScrollbar:false,
                scrollMonth:false,
                scrollTime:false,
                scrollInput:false
			});
			$("#sel").change(function () {
				$('#fm').submit();
			});

            $(".j_sort").click(function (ev) {
				ev.preventDefault();
                var target = $(".j_sort").data("url");
                var ids  = "";
                var sort = "";
                var idsEles  = $("input.selectitem");
                var sortEles = $("input.sort");
                for(var i=0;i < idsEles.length;i++){
                    ids = ids + $(idsEles[i]).val() + ",";
                    sort = sort + $(sortEles[i]).val() + ",";
                }
                console.log(ids,sort);
                var query  = {
                    ids:ids,
                    sort:sort
				};

                myUtils.ajaxpost(this, target, query);

                return false;
            });
		})
	</script>
</block>